<html>
<head>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script language="JavaScript">
	function saveObj(id){
		var url = "";
		if(id){
			url = '${request.contextPath}/xadmin/work/editWorkReport.do?reportid='+id;
		}else{
			url = '${request.contextPath}/xadmin/work/addWorkReport.do';
		}
		$('form').form('submit',{  
		    url:url,
		    onSubmit:function(){
				return $(this).form('validate')
		    },  
		    success:function(data){  
				window.top.closemodalwindow(true,data);
		    }  
		});
	}
	$(function(){
		$('#stoptime').datebox({
		    onSelect: function(date){
		   		var starttime = $('#starttime').datebox('getValue');
		   		var stoptime = $('#stoptime').datebox('getValue');
		   		if(stoptime<starttime){
			        window.top.$.messager.alert('提示',"截止日期应大于开始日期！");
			        return;
		   		}
		   		$('#myTaskgrid').datagrid('load', {dt: starttime,demo: stoptime});  
				$('#myWorkgrid').datagrid('load', {dt: starttime,content: stoptime});  
		    }
		});
		if('${obj.starttime!}'!='' && '${obj.stoptime!}'!=''){
			$('#starttime').datebox('setValue', '${obj.starttime!}');
			$('#stoptime').datebox('setValue', '${obj.stoptime!}');
		}
		
		$('#myTaskgrid').datagrid({  
         width: 'auto',  
         height:'auto',             
         striped: true,  
         singleSelect : true,  
         url:'${request.contextPath}/xadmin/work/listMyTaskLog.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         columns:[[  
             {field:'name',title: '日志名称',align: 'center',width: '150'},
             {field:'taskName',title: '所属任务',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '80',
             	formatter: function(value,rowdata,index){
             		var str =''; 
             		if(value == 0){
             			str	= '待签收';
             		}else if(value == 1){
             			str	+= '进行中';
             		}else if(value == 2){
             			str	+= '完成';
             		}
					return str;
				}
             }
         ]],
         toolbar : [{
			id : 'btndel',
			text : '加入本周总结',
			iconCls : 'icon-add',
			cls : 'right',
			handler : function() {
				toWeek($('#myTaskgrid'),$('#content'));
			}
		},{
			id : 'btndel',
			text : '加入下周计划',
			iconCls : 'icon-edit',
			cls : 'right',
			handler : function() {
				toWeek($('#myTaskgrid'),$('#nextcontent'));
			}
		}]

     });
     
     $('#myWorkgrid').datagrid({  
         width: 'auto',  
         height:'auto',             
         striped: true,  
         singleSelect : true,  
         url:'${request.contextPath}/xadmin/work/listWorkLog.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         columns:[[  
             {field:'projectName',title: '所属项目',align: 'center',width: '150'},
             {field:'content',title: '内容',align: 'center',width: '200'}
         ]],
         toolbar : [{
			id : 'btnadd',
			text : '加入本周总结',
			iconCls : 'icon-add',
			cls : 'right',
			handler : function() {
				toWeek($('#myTaskgrid'),$('#content'));
			}
		},"-",{
			id : 'btnedit',
			text : '加入下周计划',
			iconCls : 'icon-edit',
			cls : 'right',
			handler : function() {
				toWeek($('#myTaskgrid'),$('#nextcontent'));
			}
		}]

     });
	})
	function toWeek(obj,target){
		var oldval = target.val();
		var selected = obj.datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		if(oldval){
			target.val(oldval+";"+selected.name+'，'+selected.demo+'。');
		}else{
			target.val(selected.name+'，'+selected.demo+'。');
		}
	}
</script>

</head>
<body class="easyui-layout">
<div data-options="region:'east',split:true" style="width:420px;">
	<div class="easyui-tabs" data-options="fit:true">   
	    <div title="我的任务" >   
	        <table id="myTaskgrid" data-options="fit:true,border:false"></table>   
	    </div>   
	    <div title="我的工作" >   
	        <table id="myWorkgrid" data-options="fit:true,border:false"></table>  
	    </div>   
	</div>
</div>   
<div data-options="region:'center'" style="padding:5px;background:#eee;">
	<form align="center" method="post" >
		<table align=center border="1" width="95%"  cellspacing="0" cellpadding="0" style=" margin-top:10px; border-collapse: collapse; border:#ccc 1px solid;">
		<tr> 
			<td width="80" height="35" align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">周报名称：</td>
			<td width="300" bgcolor="#FFFFFF">&nbsp;
				<input name="name" class="easyui-validatebox" required="true" type="TEXT" maxlength=60  style="width:200px;" value="${obj.name!}">
			</td>
		</tr>
		<tr> 
			<td height="35" align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">时间：</td>
			<td bgcolor="#FFFFFF">&nbsp;
				<input name="starttime" id="starttime" type="text" class="easyui-datebox" style="width:160px;" required="required"></input>—
				<input name="stoptime" id="stoptime" type="text" class="easyui-datebox" style="width:160px;" required="required"></input>
			</td>
		</tr>
		<tr> 
			<td height="35" align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">本周工作总结：</td>
			<td bgcolor="#FFFFFF">&nbsp;
				<textarea rows="8" name="content" id="content" cols="55" style="width:350px;"  >${obj.content!}</textarea>
			</td>
		</tr>
		<tr> 
			<td height="35" align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">下周工作计划：</td>
			<td bgcolor="#FFFFFF">&nbsp;
				<textarea rows="8" name="nextcontent" id="nextcontent" cols="55" style="width:350px;"  >${obj.nextcontent!}</textarea>
			</td>
		</tr>
		<tr> 
			<td height="35" align="right" class="unnamed2" valign="middle" bgcolor="#FFFFFF">工作问题和建议：</td>
			<td bgcolor="#FFFFFF">&nbsp;
				<textarea rows="8" name="addcontent" cols="55" style="width:350px;"  >${obj.addcontent!}</textarea>
			</td>
		</tr>
		</table>
	</form>
</div>
</body>
</html>